﻿Imports UCBase

Public Class UCNetTester
    Implements UCBase.I_LoadSave

    Private DataIO As UCBase.I_UCNet
    Private Decoder As New UCS_HardwareIO.Decoder
    Private Sub DataOut_Connect() Handles DataOut.Connect
        Dim S As Socket = DataOut.Remote
        DataIO = S.Parent
    End Sub

    Private Sub Button3D1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3D1.Click
        Dim Data(4) As Byte

        Data = DataIO.Read(TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text, Data.Length)
        Dim S As String = "Read : Byte Array = {"
        For Each B As Byte In Data
            S = S & B.ToString & ","
        Next
        S = S.Substring(0, S.Length - 1)
        S = S & "}"
        TextBox5.Text = S
        Dim C As Integer = Decoder.Decode(Data)
        TextBox6.Text = Decoder.AddrA
        TextBox7.Text = Decoder.AddrB
        TextBox8.Text = C
        TextBox9.Text = Decoder.DataToString
    End Sub

    Public Function GetSettings() As String Implements UCBase.I_LoadSave.GetSettings
        Return TextBox1.Text & "," & TextBox2.Text & "," & TextBox3.Text & "," & TextBox4.Text
    End Function

    Public Sub SetSettings(ByVal Settings As String) Implements UCBase.I_LoadSave.SetSettings
        Dim S As String() = Settings.Split(",")
        TextBox1.Text = S(0)
        TextBox2.Text = S(1)
        TextBox3.Text = S(2)
        TextBox4.Text = S(3)
    End Sub
End Class
